<?php
function check_verify($code, $id = ''){
    $verify = new \Think\Verify();
    return $verify->check($code, $id);
}

function catList($arr,$pid=0,$level=0){
    //定义一个空数组
    $arry = [];
    //循环查询出来的结果
    foreach ($arr as $key => $value) {
        //$arry['cat_name'] = $value['cat_name'];
        //从最高层开始判断
        if($value['parent_id']==$pid){
            // $this->xxx[$i]['lv'] = str_repeat('&nbsp;&nbsp;&nbsp;',$level).$value['cat_name'];
            // $this->xxx[$i]=$value;
            // $this->xxx[$i]['cat_name'] = $this->xxx[$i]['lv'].$this->xxx[$i]['cat_name'];
            //$a = $value['cat_id'];
            $value['lvnum'] = $level;
            //给$value数组添加一个用来区分和父级栏目区域的东东
            $value['lv'] = str_repeat('&nbsp;&nbsp;&nbsp;',$level);
            //把value数组赋值给$arry
            $arry[] = $value;
            //用递归的方式继续执行
            $arry = array_merge($arry,catList($arr,$value['cat_id'],$level+1));
        }
    }
    //print_r($arry);
    return $arry;
}
 ?>
